<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@page isELIgnored="false" %>
<%@include file="common/head.jsp" %>
<style type="text/css">
    .pagination {
        overflow: hidden;
        margin: 0;
        padding: 10px 10px 6px 10px;
        border-top: 1px solid #f60;
        _zoom: 1;
    }

    .pagination * {
        display: inline;
        float: left;
        margin: 0;
        padding: 0;
        font-size: 12px;
    }

    .pagination i {
        float: none;
        padding-right: 1px;
    }

    .currentPage b {
        float: none;
        color: #f00;
    }

    .pagination li {
        list-style: none;
        margin: 0 5px;
    }

    .pagination li li {
        position: relative;
        margin: -2px 0 0;
        font-family: Arial, Helvetica, sans-serif
    }

    .firstPage a, .previousPage a, .nextPage a, .lastPage a {
        overflow: hidden;
        height: 0;
        text-indent: -9999em;
        border-top: 8px solid #fff;
        border-bottom: 8px solid #fff;
    }

    .pagination li li a {
        margin: 0 1px;
        padding: 0 4px;
        border: 3px double #fff;
    + border-color: #eee;
        background: #eee;
        color: #06f;
        text-decoration: none;
    }

    .pagination li li a:hover {
        background: #f60;
        border-color: #fff;
    + border-color: #f60;
        color: #fff;
    }

    li.firstPage {
        margin-left: 40px;
        border-left: 3px solid #06f;
    }

    .firstPage a, .previousPage a {
        border-right: 12px solid #06f;
    }

    .firstPage a:hover, .previousPage a:hover {
        border-right-color: #f60;
    }

    .nextPage a, .lastPage a {
        border-left: 12px solid #06f;
    }

    .nextPage a:hover, .lastPage a:hover {
        border-left-color: #f60;
    }

    li.lastPage {
        border-right: 3px solid #06f;
    }

    li li.currentState a {
        position: relative;
        margin: -1px 3px;
        padding: 1px 4px;
        border: 3px double #fff;
    + border-color: #f60;
        background: #f60;
        color: #fff;
    }

    li.currentState, .currentState a, .currentState a:hover {
        border-color: #fff #ccc;
        cursor: default;
    }
</style>


<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>用户管理页面</span>
    </div>
    <div class="search">
        <h3>${message}</h3>
        <form method="get" action="${pageContext.request.contextPath }/user/query">
            <%--		<input name="method" value="query" class="input-text" type="hidden">--%>
            <span>用户名：</span>
            <input name="queryUserName" class="input-text" type="text" value="${queryUserName }">

            <span>用户角色：</span>
            <select name="queryUserRole">
                <c:if test="${roleList!= null }">
                    <option value="0">--请选择--</option>
                    <c:forEach var="role" items="${roleList}">
                        <option
                                <c:if test="${role.id == queryUserRole }">selected="selected"</c:if>
                                value="${role.id}">${role.roleName}</option>
                    </c:forEach>
                </c:if>
            </select>

            <%--	 <input type="hidden" name="pageIndex" value="1"/>--%>
            <input value="查 询" type="submit" id="searchbutton">
            <a href="${pageContext.request.contextPath}/userAdd2">添加用户</a><br>
            <a href="${pageContext.request.contextPath}/goDelete">删除用户</a>
        </form>
    </div>

    <!--用户-->
    <table class="providerTable" cellpadding="0" cellspacing="0">
        <tr class="firstTr">
            <th width="10%">用户编码</th>
            <th width="20%">用户名称</th>
            <th width="10%">性别</th>
            <th width="10%">年龄</th>
            <th width="10%">电话</th>
            <th width="10%">用户角色</th>
            <th width="30%">操作</th>
        </tr>
        <c:forEach var="user" items="${pageInfo.list}">
            <tr>
                <td>
                    <span>${user.userCode }</span>
                </td>
                <td>
                    <span>${user.userName }</span>
                </td>
                <td>
							<span>
								<c:if test="${user.gender==1}">男</c:if>
								<c:if test="${user.gender==2}">女</c:if>
							</span>
                </td>
                <td>
                            <span>
                             <%-- <fmt:formatDate value="${user.birthday}" pattern="yyyy-MM-dd hh:mm:ss"/>--%>
                                ${user.age}
                            </span>
                </td>
                <td>
                    <span>${user.phone}</span>
                </td>
                <td>
                    <span>${user.roleName}</span>
                </td>
                <td>
                    <span><a class="viewUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
                            src="${pageContext.request.contextPath }/statics/images/read.png" alt="查看" title="查看"/></a></span>
                    <span><a class="modifyUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
                            src="${pageContext.request.contextPath }/statics/images/xiugai.png" alt="修改"
                            title="修改"/></a></span>
                    <span><a class="deleteUser" href="javascript:deleteUser(${user.id});"
                             userid=${user.id } username=${user.userName }><img
                            src="${pageContext.request.contextPath }/statics/images/schu.png" alt="删除" title="删除"/></a></span>
                </td>
            </tr>
        </c:forEach>
    </table>

    <ul class="pagination">
        <li class="totalAnnal">总记录数：<i>${pageInfo.total}</i></li>
        <li class="totalPage">总页数：<i>${pageInfo.pages}</i></li>
        <li class="currentPage">当前页：<b>${pageInfo.pageNum}</b></li>


        <%--当页码==1时则隐藏上一页和首页--%>
        <c:choose>
            <c:when test="${pageInfo.pageNum==1}">
            </c:when>
            <c:otherwise>
                <li class="previousPage">
                    <a href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${pageInfo.pageNum-1}"><span
                            class="page-link">上一页</span></a>
                </li>
            </c:otherwise>
        </c:choose>

        <li>
            <ol>
                <%--当页码小于等于6页是--%>
                <c:choose>
                    <c:when test="${pageInfo.pages<=10}">
                        <c:forEach var="c" begin="1" step="1" end="${pageInfo.pages}">
                            <c:choose>
                                <c:when test="${c==pageInfo.pageNum}">
                                    <li class="currentState"><a class="page-link"
                                                                href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                    </li>
                                </c:when>
                                <c:otherwise>
                                    <li><a class="page-link"
                                           href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                    </li>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>


                        <c:choose>
                            <%--最多页码为10页--%>
                            <c:when test="${pageInfo.pageNum<=6}">

                                <c:forEach begin="1" end="10" var="c">
                                    <c:choose>
                                        <c:when test="${c==pageInfo.pageNum}">
                                            <li class="currentState"><a class="page-link"
                                                                        href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                            </li>
                                        </c:when>
                                        <c:otherwise>
                                            <li><a class="page-link"
                                                   href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                            </li>
                                        </c:otherwise>
                                    </c:choose>
                                </c:forEach>
                            </c:when>

                            <%--当页码超过6页是,则开始为页码为pageNum-5到pageNum+4--%>
                            <c:otherwise>
                                <c:forEach var="c" begin="${pageInfo.pageNum-5}" end="${pageInfo.pageNum+4}">
                                    <c:choose>
                                        <c:when test="${pageInfo.pages<c}">

                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when test="${c==pageInfo.pageNum}">
                                                    <li class="currentState"><a class="page-link"
                                                                                href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                                    </li>
                                                </c:when>
                                                <c:otherwise>
                                                    <li><a class="page-link"
                                                           href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                                    </li>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:otherwise>
                                    </c:choose>

                                </c:forEach>
                            </c:otherwise>
                        </c:choose>
                    </c:otherwise>
                </c:choose>
                </li>
            </ol>

            <c:choose>
            <c:when test="${pageInfo.pageNum<pageInfo.pages}">
        <li class="nextPage">
            <a href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${pageInfo.pageNum+1}"><span
                    class="page-link">下一页</span></a>
        </li>
        </c:when>
        <c:otherwise>

        </c:otherwise>
        </c:choose>
        <%--     <c:choose>
                 <c:when test="${pageInfo.pageNum==1}">
                     <li class="previousPage currentState">
                         <a href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${pageInfo.pageNum-1}"><span
                                 class="page-link">上一页</span></a>
                     </li>
                 </c:when>
                 <c:otherwise>
                     <li class="previousPage">
                         <a href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${pageInfo.pageNum-1}"><span
                                 class="page-link">上一页</span></a>
                     </li>
                 </c:otherwise>
             </c:choose>

             <li>
                 <ol>
                     <c:forEach var="c" begin="1" step="1" end="${pageInfo.pages}">
                         <c:choose>
                             <c:when test="${c==pageInfo.pageNum}">
                                 <li class="currentState"><a class="page-link"
                                                             href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                 </li>
                             </c:when>
                             <c:otherwise>
                                 <li><a class="page-link"
                                        href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${c}">${c}</a>
                                 </li>
                             </c:otherwise>
                         </c:choose>
                     </c:forEach>
                 </ol>
             </li>

             <c:choose>
                 <c:when test="${pageInfo.pageNum==pageInfo.pages}">
                     <li class="nextPage currentState">
                         <a href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${pageInfo.pageNum+1}"><span
                                 class="page-link">下一页</span></a>
                     </li>
                 </c:when>
                 <c:otherwise>
                     <li class="nextPage">
                         <a href="/user/query?queryUserName=${queryUserName}&queryUserRole=${queryUserRole}&currentPageNo=${pageInfo.pageNum+1}"><span
                                 class="page-link">下一页</span></a>
                     </li>
                 </c:otherwise>
             </c:choose>--%>

    </ul>
    <div class="providerView">
        <p><strong>用户编号：</strong><span id="_userCode"></span></p>
        <p><strong>用户名称：</strong><span id="_userName"></span></p>
        <p><strong>用户性别：</strong>
            <span id="_gender"></span>
        </p>
        <p><strong>出生日期：</strong>
            <span id="_birthday"></span></p>
        <p><strong>用户电话：</strong><span id="_phone"></span></p>
        <p><strong>用户地址：</strong><span id="_address"></span></p>
        <p><strong>用户角色：</strong><span id="role"></span></p>
        <input type="hidden" id="totalPageCount" value="${totalPageCount}"/>
    </div>
    </section>

    <!--点击删除按钮后弹出的页面-->
    <div class="zhezhao"></div>
    <div class="remove" id="removeUse">
        <div class="removerChid">
            <h2>提示</h2>
            <div class="removeMain">
                <p>你确定要删除该用户吗？</p>
                <a href="#" id="yes">确定</a>
                <a href="#" id="no">取消</a>
            </div>
        </div>
    </div>
    <%@include file="common/foot.jsp" %>
    <script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/userlist.js"></script>
